home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 14160 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.6 KB  |  73 lines

  1. Path: an158.du.pipex.com!alanshepherd
  2. From: alanshepherd@online.rednet.co.uk (Alan Shepherd)
  3. Newsgroups: comp.lang.c++
  4. Subject: MSVC 1.5 problem using CString class and fstream
  5. Date: Thu, 28 Mar 1996 10:16:48
  6. Organization: Link Technology Ltd
  7. Message-ID: <alanshepherd.28.000A4801@online.rednet.co.uk>
  8. NNTP-Posting-Host: an158.du.pipex.com
  9. X-Newsreader: Trumpet for Windows [Version 1.0 Rev A]
  10.  
  11. Hello I am a newby to C++, MSVC and this group so please forgive if this 
  12. question is naive or has been posted previously.
  13.  
  14. I am having problems in two areas and I suspect they are related. The first 
  15. occours when I tried to write a simple C++ program using CString types. A
  16. simple quickwin example is shown below.
  17.  
  18. #include <iostream.h>
  19. #include<afx.h>
  20.  
  21. int CStringfunc( CString&, CString&);
  22.  
  23. CString line = "this is a test of CStringfunc";
  24. CString word = "test";
  25.  
  26. void main()
  27. {
  28.      int i = CStringfunc(line,word);
  29.     cout << " i = " << i << '\n';
  30. }
  31. .
  32. definition of CStringfunc etc.
  33. .
  34.  
  35. The code compiles ok but the linker complains that .."mlibcew(delete.cxx) : 
  36. error l2044: void __far __cdecl operator delete(void __near*) symbol multiply 
  37. defined" followed by some advice on relinking with /NOE (which also does not 
  38. work. The same message is repeated for "operator new"
  39.  
  40. this is followed by a list of L2029 errors (unresolved externals) including;
  41. GETFILETITLE...DRAGACCEPTFILES...CHOOSECOLOR etc. I have experimented with
  42. including various libraries in the link options with no sucess. Any sugestions?
  43.  
  44. The second problem is similar but comes at it from the oposite direction. In 
  45. this case I wish to use <fstream.h> in my appwizzard generated widows program. 
  46. I wanted to do some simple text file i/o and thought the fstream class gave 
  47. better service than the CStdiofile class. The work was just some anciliary 
  48. bookkeeping and so I didnt want to go the serialise/archive route. I include 
  49. the header file references for example
  50.  
  51. #include "stdafx.h"
  52. #include "appro.h"
  53. #include "project.h"
  54. #include "logon.h"
  55.  
  56. #include "fstream.h"
  57. #include "direct.h"
  58. #include "sys\types.h"
  59. #include "sys\stat.h"
  60. .
  61. .
  62. Again the code compiles ok but does not link with exactly the same L2044 error 
  63. on the 'new' and 'delete' operators. I have written a seperate small program 
  64. using fstream it works fine UNTILL I include <afx.h>. Are these seperate ways 
  65. of working incompatable or am I doing something wrong? I cant seem to use the 
  66. CString class outside the application framework or the fstream class within.
  67. If anyone else has had similar problems to this or any advice at all I would 
  68. be greatful to hear from them.
  69.  
  70. alanshepherd@online.rednet.co.uk
  71.  
  72.  
  73.